-
Notifications
You must be signed in to change notification settings - Fork 24
perf(votes): add attestation caching #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix-ABI-parsing
Are you sure you want to change the base?
Conversation
src/node/evm/pre_execution.rs
Outdated
| LazyLock::new(|| Mutex::new(HashMap::new())); | ||
|
|
||
| static BLS_PUBKEY_CACHE: LazyLock<Mutex<BlsPublicKeyCache>> = | ||
| LazyLock::new(|| Mutex::new(HashMap::new())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SNAPSHOT_FINGERPRINT_CACHE / BLS_PUBKEY_CACHE: Are there memory issues if the instance runs for an extended period of time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds caching to attestation verification to improve performance. According to the flamegraph analysis, verify_vote_attestation and the underlying BLST signature verification were consuming over 10% of total execution time. The changes introduce three new caches to avoid redundant cryptographic operations and validator set processing.
- Adds attestation verification result caching to skip expensive BLS signature verification for already-validated attestations
- Implements snapshot fingerprinting and BLS public key caching to reuse parsed cryptographic objects
- Refactors validator address derivation into a dedicated method to eliminate code duplication
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/node/evm/pre_execution.rs | Adds three new caches (attestation verification, snapshot fingerprint, BLS public keys) and integrates them into the attestation verification flow. Includes unit tests for cache behavior. |
| src/node/miner/config.rs | Refactors validator address derivation logic into the new derive_validator_address_from_keys() method and updates tests to use shared helper functions. |
| src/rpc/mev.rs | Simplifies MEV API initialization by removing inline key derivation logic and relying solely on the configured validator address. |
| src/main.rs | Adds explicit error handling for validator address derivation during mining configuration setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
20a4ecd to
f52ad0f
Compare
Description
In the original flamegraph (run before any caching),
reth_bsc::node::evm::pre_execution::verify_vote_attestationaccounted for 5.49 % of total samples and the BLSTSignature::fast_aggregate_verifyunderneath it took another 5.32 %.